/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package system.general;

import java.util.ResourceBundle;
import javax.el.ELContext;
import javax.faces.context.FacesContext;

/**
 *
 * @author gilberto-CIDITIC
 */
public class Label {

    Logged logged;
    private ResourceBundle rb;
    private String module;

    public Label() {
        ELContext elContext = FacesContext.getCurrentInstance().getELContext();
        logged = (Logged) FacesContext.getCurrentInstance().getApplication().getELResolver().getValue(elContext, null, "logged");
    }

    private void loadBundle() {
        String idiom = "es";
        if (!logged.getLoggedIdiom().toLowerCase().equals("")) {
            idiom = logged.getLoggedIdiom().toLowerCase();
        }
        rb = ResourceBundle.getBundle(module + ".label_" + idiom);
    }

    public String name(String module, String idl) {
        this.module = module;
        loadBundle();
        return rb.getString(idl);
    }
}